import React, { Component } from 'react';
import { connect } from 'dva';
import { Table,Divider,Icon,Button,message } from 'antd';


@connect(state => ({
  touchUser:state.touchUser
}))
export default class Test1 extends Component {


  componentDidMount() {
    this.props.dispatch({
      type: 'touchUser/getAllUser',
    });
  }
  handleClickUpdate(e){
    message.info("点击新增按钮");
  }
  render(){
    const {touchUser:data} = this.props
    const {users} = data
    users.map((u,index)=> {
      return u.key=index+1;
      }
    )
    const dataSource = users;
    const columns = [{
      title: '姓名',
      dataIndex: 'name',
      key: 'name',
    }, {
      title: '密码',
      dataIndex: 'password',
      key: 'password',
    }, {
      title: '创建时间',
      dataIndex: 'createDate',
      key: 'createDate',
      render:(text, record, index)=>{
        var unixTimestamp = new Date( text ) ;
        return unixTimestamp.toLocaleString();
      }
    }, {
      title: '操作',
      key: 'action',
      render: (text, record) => (
        <span>
            <a href="javascript:;">Action 一 {record.name}</a>
          <Button type="primary"    onClick={this.handleClickUpdate} icon='plus'>编辑</Button>
            <Divider type="vertical" />
            <a href="javascript:;">Delete</a>
            <Divider type="vertical" />
            <a href="javascript:;" className="ant-dropdown-link">
              More actions <Icon type="down" />
            </a>
        </span>
      ),
    }
    ];
    return(
      <div>
        <Table
          dataSource={dataSource}
          columns={columns}
          bordered
          // loading
        />
      </div>
      )
  }
}

